import 'package:dio/dio.dart';
import 'package:distribution_mall_flutter/constant/http_constant.dart';
import 'package:distribution_mall_flutter/http/init.dart';
import 'package:distribution_mall_flutter/pages/merchant_authentication/domain/merchant_auth_last_entity.dart';

//商户认证
class MerchantAuthenticationApi {
  //获取最新认证信息
  static Future<Result<MerchantAuthLastBody>> queryLast({CancelToken? cancelToken}) async {
    return (await Request(HttpConstant.getDomain.mallManagerApiGatewayUrl,
            '/distribution-mall-biz/distributor-certificate/queryLast')
        .request<MerchantAuthLastBody>(httpMethod: HttpMethod.get,cancelToken: cancelToken));
  }

  //提交认证信息
  static Future<Result<dynamic>> apply({
    required String businessName,
    required String certificateNo,
    required String businessPermitUrl,
    required String countryCode,
    required String callingNumber,
    required String country,
    required String? province,
    required String? city,
    required String? district,
    required String? street,
    required String? detailed,
  }) async {

    return (await Request(HttpConstant.getDomain.mallManagerApiGatewayUrl,
            '/distribution-mall-biz/distributor-certificate/apply')
        .request<String>(
            httpMethod: HttpMethod.post,
            params: {
              'certificateType': 'BUSINESS_PERMIT',
              'businessName': businessName,
              'certificateNo': certificateNo,
              'businessPermitUrl': businessPermitUrl,
              'phoneNumber': {
                'countryCode': countryCode,
                'callingNumber': callingNumber,
              },
              'address':{
               'country': country,
               'province': province,
               'city': city,
               'district': district,
               'street': street,
               'detailed': detailed,
              }
            },
            showLoadingIndicator: true));
  }
}
